from flask import Blueprint, jsonify
from flask import request
from dao import bank_dao



blue = Blueprint('bankBlue',__name__)

@blue.route('/bank',methods=['GET','POST'])
def bank():
    dao = bank_dao.BankDao()
    data = dao.find_all()
    return jsonify({
        'status':20,
        'message':'find all ok',
        'data':data
    })

@blue.route('/edit/<int:bankId>',methods=['GET'])
def edit(bankId):
    return "正在编辑：银行编号%s"%bankId


@blue.route('/del<int:bank_id>',methods=['DELETE'])
def defBank(bank_id):
    return "  <h3>正在删除银行:%s</h3> "%(bank_id)

@blue.route('/find/<keyword>/',methods=['GET'])
def find(keyword):
    return "keyword是什么类型%s类型，值是%s"%(type(keyword),keyword)

@blue.route('/forward/<path:url>',methods=['GET'])
def forward(url):
    return """
        <script>
            let steps = 5
            let id = setInterval(()=>{
                if(steps>=1){
                    document.write("<br>剩余"+ (--steps)+"秒");
                }else{
                    open("%s",target="_self")
                }
            },1000)
        </script>
    """%url